<!DOCTYPE HTML>
<html>
<head>
    <title>执行力管理</title>
    <link rel="stylesheet" href="/stylesheets/style.css">
    <script src="/scripts/jquery.min.js"></script>
    <script src="/scripts/boot.js" type="text/javascript"></script>
    <link rel="stylesheet" href="/scripts/miniui/themes/default/miniui.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/icons.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/bootstrap/skin.css">
    <link rel="stylesheet" href="/editor/common.css">
    <script src="/scripts/miniui/miniui.js"></script>
</head>
<body  style="padding: 0;width: 100%;height: 98%">
<div style="width:100%;height:87%;">
    <div showCollapseButton="true" style="width: 100%;height: 100%">

        <div style="width:99%;">
            <div class="mini-toolbar" style="border-bottom:0;padding:0px;">
                <table style="width:100%;">
                    <tr>
                        <td style="width:100%;">
                            <a class="mini-button" iconCls="icon-edit" onclick="smallRoutineEdit()">编辑</a>
                        </td>
                    </tr>
                </table>
            </div>
        </div>

        <div id="datagrid1" class="mini-datagrid" style="width:99%;height: 63%;"
             url="/getdata/smallRoutineVersion" idField="id" allowResize="true" onSelectionChanged="onSelectionChanged"
             sizeList="[20,30,50,100]" pageSize="20"
        >
            <div property="columns">
                <div type="checkcolumn" width="15"></div>
                <div field="objectId" width="60" align="center" align="center" headerAlign="center">objectId</div>
                <div field="version" width="80" align="center" align="center" headerAlign="center">版本号</div>
                <div field="name" width="80" align="center" align="center" headerAlign="center">name</div>
                <div field="createdAt" width="40" align="center" headerAlign="center">创建日期</div>
                <div field="updatedAt" width="40" align="center" headerAlign="center">更新日期</div>
            </div>
        </div>
        <h2>模板管理</h2>
        <div style="width:99%;">
            <div class="mini-toolbar" style="border-bottom:0;padding:0px;">
                <table style="width:100%;">
                    <tr>
                        <td style="width:100%;">
                            <a class="mini-button" iconCls="icon-add" onclick="tempAdd()">增加</a>
                            <a class="mini-button" iconCls="icon-edit" onclick="tempEdit()">编辑</a>
                            <a class="mini-button" iconCls="icon-remove" onclick="tempRemove()">删除</a>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        <div id="datagrid2" class="mini-datagrid" style="width:99%;height:30%;" url="/getdata/findForTemplate"
             sizeList="[20,30,50,100]" pageSize="20" idField="id"  allowResize="true" >
            <div property="columns">
                <div type="checkcolumn" width="15" ></div>
                <div field="objectId" width="60" align="center" align="center" headerAlign="center">objectId</div>
                <div field="content" width="80" align="center" align="center" headerAlign="center">内容</div>
                <div field="name" width="60" align="center" align="center" headerAlign="center">名称</div>
                <div field="webAppOId" width="60" align="center" align="center" headerAlign="center">版本Id</div>
                <div field="createdAt" width="40" align="center" headerAlign="center">创建日期</div>
                <div field="updatedAt" width="40" align="center" headerAlign="center">更新日期</div>
            </div>
        </div>
    </div>

</div>
</body>
<script type="text/javascript">
    var objectId;
    mini.parse();
    var grid2 = mini.get("datagrid1");
    var grid3 = mini.get("datagrid2");


    grid2.load();
    function onSelectionChanged(e) {
        var tribeGrid = e.sender;
        var record = tribeGrid.getSelected();
        if (record) {
            objectId = record.objectId;
            grid3.load({objectId:record.objectId});
        }
    }

    function smallRoutineEdit() {
        var row2 = grid2.getSelected();
        if (row2) {
            mini.open({
                url: "/getdata/smallRoutineVersion/edit?objectId=" + row2.objectId,
                title: "版本信息", width: 400, height: 250,
                ondestroy: function (action) {
                    grid2.reload();
                }
            });
        } else {
            alert("请选中一个成员!");
            return;
        };

    }
    ;

    function tempAdd() {
        if(objectId =="" ||objectId ==undefined ||objectId==null){
            alert("请选择一个版本")
            return
        }
        mini.open({
            url:"/getdata/templateForThreadAdd?objectId="+objectId,
            title: "增加模板", width: 600, height: 600,
            ondestroy: function (action) {
                grid3.reload();
            }
        })
    }
    
    function tempEdit() {
        let row = grid3.getSelected();
        if(row){
            mini.open({
                url:"/getdata/temEdit?objectId="+row.objectId,
                title: "编辑", width: 400, height: 250,
                ondestroy: function (action) {
                    grid3.reload();
                }
            })
        }else{
            alert("请选择一条记录")
        }
    }
    
    function tempRemove() {
        let row = grid3.getSelected();
        if(row){
            $.ajax({
                url:"/getdata/temDelete",
                type:"post",
                data:{
                    objectId:row.objectId
                },
                success:function (result) {
                    if(result =="10001"){
                        alert("删除成功");
                        grid3.reload();
                    }else {
                        alert("删除失败")
                    }
                }

            })
        }
    }
</script>
</html>
